package com.liang.auth.domain.service.impl;

import com.liang.auth.domain.bo.AuthRoleBO;
import com.liang.auth.domain.convert.AuthRoleBOConverter;
import com.liang.auth.domain.service.AuthRoleDomainService;
import com.liang.auth.infra.basic.entity.AuthRole;
import com.liang.auth.infra.basic.service.AuthRoleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    private final AuthRoleService authRoleService;

    @Override
    public void save(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBO2PO(authRoleBO);
        log.info("AuthRoleDomainServiceImpl.save.authRole：{}", authRole);
        authRoleService.save(authRole);
    }

    @Override
    public void update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBO2PO(authRoleBO);
        log.info("AuthRoleDomainServiceImpl.update.authRole：{}", authRole);
        authRoleService.updateById(authRole);
    }

    @Override
    public void delete(Long roleId) {
        authRoleService.removeById(roleId);
    }
}
